import java.util.ArrayList;
import java.util.List;

/**
 * Created by maizhipeng on 2017/5/29.
 */

public class Parser {
    private List<Node> mNodeList = new ArrayList<>();

    public List<Node> getNodeList() {
        return mNodeList;
    }

    public void createNode(String regex) {
        for (int i = 0; i < regex.toCharArray().length; i++) {
            Node node = new Node();

            char c = regex.toCharArray()[i];
            if (isLetter(c)) node.setChar(c);
            if (isOperation(c) && mNodeList.size()>0) {
                Node lastNode = mNodeList.get(mNodeList.size() - 1);
                node.addOperation(c);
                node.setLeft(lastNode);

            }

            mNodeList.add(node);
        }


    }

    private boolean isLetter(char c) {
        if ((c <= 'Z' && c >= 'A')
                || (c <= 'z' && c >= 'a')) {
            return true;
        } else {
            return false;
        }

    }

    private boolean isOperation(char c) {
        if ((c == '*' || c == '+')) {
            return true;
        } else
            return false;
    }


}
